package com.daihou.BCJ.decrease;

import com.daihou.BCJ.repayment.BalanceRepayment;
import com.daihou.config.TheAuth;
import com.daihou.model.ceres.DecreaseUrlEnum;
import com.daihou.utils.DHConfigFile;
import com.daihou.utils.DHHttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @author liujintao
 * @date 2021/2/8 10:37
 */
public class ConfiscateQuotaQuery {
    private static final Logger logger = LoggerFactory.getLogger(BalanceRepayment.class);
    private String url;
    Map<String, String> headers = new HashMap<>();

    @BeforeTest(description = "测试准备工作,获取Authorization对象")
    public void beforeTest() throws IOException {
        url = DHConfigFile.getUrl("DaiHou_URL", "decrease", DecreaseUrlEnum.DECREASEQUOTACONFISCATE.toString());
        //设置请求头中的Authorization
        headers.put("Authorization", TheAuth.getAuth());
        headers.put("X-UserName", "admin");
    }

    @Test(description = "没收额度")
    public void classifyLogQueryTest() {
        String body="{\"userId\":17030,\"productType\":[{\"productTypeCode\":\"HAOHUAN\",\"productTypeName\":\"好还\",\"conf\":[{\"divisionMonthlyOverDueLevel\":\"43\",\"stageName\":\"HH-2\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":10,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":10},{\"divisionMonthlyOverDueLevel\":\"56\",\"stageName\":\"2342354\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"58\",\"stageName\":\"44\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"60\",\"stageName\":\"1\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"61\",\"stageName\":\"3\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"62\",\"stageName\":\"4\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"63\",\"stageName\":\"5\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"64\",\"stageName\":\"7\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"65\",\"stageName\":\"77\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"66\",\"stageName\":\"88\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"68\",\"stageName\":\"003333\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0}]},{\"productTypeCode\":\"RRD\",\"productTypeName\":\"人人贷借款\",\"conf\":[{\"divisionMonthlyOverDueLevel\":\"54\",\"stageName\":\"rr-60\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"67\",\"stageName\":\"99\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"71\",\"stageName\":\"100\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0},{\"divisionMonthlyOverDueLevel\":\"72\",\"stageName\":\"27\",\"monthInitQuota\":0,\"assignedQuota\":0,\"confiscatedQuota\":0,\"availableQuota\":0,\"currentActualQuota\":0,\"currentAvailableQuota\":0,\"assigningQuota\":0,\"confiscateQuota\":0}]}],\"userCode\":\"liujintao\",\"userName\":\"刘锦涛\",\"orgId\":154,\"orgCode\":\"root\",\"orgName\":\"A组\"}";
        String result = Objects.requireNonNull(DHHttpUtil.post_with_String(url, body, headers)).toJSONString();
        logger.info("没收额度结果：{}", result);
        Assert.assertTrue(result.contains("\"message\":\"操作成功\",\"status\":\"0\""));
    }
}